package com.josework.springhelloworld.utils;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;

public class DateUtils {
    /**
     *
     * @return  LocalDateTime 转UTC时间
     */
    public static LocalDateTime UTCDATE(){
        return LocalDateTime.now().atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneId.of("UTC")).toLocalDateTime();
    }

    /**
     *
     * @param date  指定日期
     * @param weeks 指定周数
     * @return
     *
     * 例如传入 2021/11/4，1 得到 下一个周四的日期 2021/11/11
     */
    public static LocalDate fethchNextWeeksDate(LocalDate date,int weeks){
        int value = date.getDayOfWeek().getValue();
        LocalDate result = date.plusWeeks(weeks).with(DayOfWeek.of(value));
        return  result;
    }
}
